#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// PandoraFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using System;
using UnityEngine;

namespace PandoraEditor
{
    public static class UserSetting
    {
        [NonSerialized] public const string version = "Pandora Version:2.01";
        private static CompileSetting m_CompileSetting;
        private static UISetting m_UISetting;
        private static ProtocolSetting m_ProtocolSetting;
        private static CheckSetting m_CheckSetting;
        private static VersionSetting m_VersionSetting;
        private static AccountSetting m_AccountSetting;
        public static CompileSetting CompileSetting => m_CompileSetting ??= SettingHelper.LoadSettings<CompileSetting>();
        public static UISetting UISetting => m_UISetting ??= SettingHelper.LoadSettings<UISetting>();
        public static ProtocolSetting ProtocolSetting => m_ProtocolSetting ??= SettingHelper.LoadSettings<ProtocolSetting>();
        public static CheckSetting CheckSetting => m_CheckSetting ??= SettingHelper.LoadSettings<CheckSetting>();
        public static VersionSetting VersionSetting => m_VersionSetting ??= SettingHelper.LoadSettings<VersionSetting>();
        public static AccountSetting AccountSetting => m_AccountSetting ??= SettingHelper.LoadSettings<AccountSetting>();

        public static void Clear()
        {
            m_CompileSetting = null;
            m_UISetting = null;
            m_ProtocolSetting = null;
            m_CheckSetting = null;
        }

        public static void SaveAll()
        {
            SettingHelper.SaveSingleSetting(CompileSetting);
            SettingHelper.SaveSingleSetting(UISetting);
            SettingHelper.SaveSingleSetting(ProtocolSetting);
            SettingHelper.SaveSingleSetting(CheckSetting);
            SettingHelper.SaveSingleSetting(VersionSetting);
            SettingHelper.SaveSingleSetting(AccountSetting);
        }
    }
}